﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace ViewLED
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        
        UI.Index pindex = new UI.Index();

        public MainWindow()
        {
            // 初始化主窗体组件
            InitializeComponent();
            // 设置主窗体关闭时屏幕子窗体也自动关闭
            Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
        }

        // 点击btnText文字效果按钮展示Ptext.xaml效果
        private void btnText_Click(object sender, RoutedEventArgs e)
        {
            UI.Ptext ptext = new UI.Ptext();  // 创建新效果实例
            fraMain.Navigate(ptext);          // 右侧显示内容切换到该实例
            setButton();                      // 设置按钮
            Button btn = (Button)sender;      // 被点击切换到本效果的出发按钮背景变红
            btn.Background = Brushes.Red;
        }

        // 点击btnPic图片效果按钮展示Ppicture.xaml效果
        private void btnPic_Click(object sender, RoutedEventArgs e)
        {
            UI.Ppicture ppic = new UI.Ppicture();
            fraMain.Navigate(ppic);
            setButton();
            Button btn = (Button)sender;
            btn.Background = Brushes.Red;
        }

        // 点击btnVideo视频效果按钮展示Pvideo.xaml效果
        private void btnVideo_Click(object sender, RoutedEventArgs e)
        {
            UI.Pvideo pvideo = new UI.Pvideo();
            fraMain.Navigate(pvideo);
            setButton();
            Button btn = (Button)sender;
            btn.Background = Brushes.Red;
        }

        // 设置按钮背景色
        private void setButton()
        {
            btnIndex.Background = new SolidColorBrush(Color.FromRgb(22, 188, 92));
            btnText.Background = new SolidColorBrush(Color.FromRgb(22,188,92));
            btnPic.Background = new SolidColorBrush(Color.FromRgb(22, 188, 92));
            btnMain.Background = new SolidColorBrush(Color.FromRgb(22, 188, 92));
            btnVideo.Background = new SolidColorBrush(Color.FromRgb(22, 188, 92));
            Model.ScreenManager.closeScreen();
        }

        // 切换到欢迎页面
        private void btnIndex_Click(object sender, RoutedEventArgs e)
        {
            fraMain.Navigate(pindex);
            setButton();
            Button btn = (Button)sender;
            btn.Background = Brushes.Red;
        }

        // 屏幕播放设置
        private void btnSet_Click(object sender, RoutedEventArgs e)
        {
            //点击btnMain按钮展示Psetting.xaml效果
            UI.Psetting ps = new UI.Psetting();
            fraMain.Navigate(ps); 
            setButton();
            Button btn = (Button)sender;
            btn.Background = Brushes.Red;
        }
    }
}
